package com.xinqi.modules.course.clazz.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.common.core.enums.ClassRoleEnum;
import com.xinqi.modules.course.clazz.client.ClassStudentClient;
import com.xinqi.modules.course.clazz.dto.req.ClassStudentQueryDTO;
import com.xinqi.modules.course.clazz.dto.rsp.ClassStudentResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 班级降级处理
 *
 * @author: system
 * @date: 2023/01/12
 */
@Slf4j
@Component
public class ClassStudentFallbackFactory implements FallbackFactory<ClassStudentClient> {

    @Override
    public ClassStudentClient create(Throwable throwable) {
        log.error("课程服务调用失败:{}", throwable.getMessage());
        return new ClassStudentClient() {

            @Override
            public R<PageInfo<ClassStudentResultDTO>> page(ClassStudentQueryDTO dto) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<ClassStudentResultDTO> findById(Long id) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<Boolean> checkIsStudent(Long classId, Long userId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> studentListByClassId(Long classId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> allUserListByClassId(Long classId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> findByClassIdListAndRoleList(List<Long> classIdList, List<ClassRoleEnum> roles) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<ClassStudentResultDTO> findByStudentId(Long classId, Long userId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> findByStudentIds(Long classId, List<Long> userId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<ClassStudentResultDTO> checkRole(Long classId, Long userId, List<ClassRoleEnum> classRoles) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> findContainsTeacherListByClassId(Long classId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<ClassStudentResultDTO> findAllRolesStudentByClassIdAndStudentId(Long classId, Long studentId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<ClassStudentResultDTO> findVirtualClassStudentByClassIdAndUserId(Long classId, Long userId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> findClassMasterStudentByClassId(Long classId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> findClassMasterStudentByClassIdList(List<Long> classIdList) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<List<ClassStudentResultDTO>> findClassRelationshipStudentList(Long classId, List<Long> studentIds) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

        };
    }
}
